package org.eclipse.assemblyformatter.ir.lowlevel;

import org.eclipse.assemblyformatter.ir.Section;

public class WhiteSpace extends Section {
	private int virtualLength;

	public WhiteSpace() {
		virtualLength = Integer.MIN_VALUE; // negative value stands for
											// "Don't change"
	}

	public void setVirtualLength(int virtualLength) {
		// Set virtual length only if this is necessary.
		// Do not make unnecessary document modifications.
		if (this.getLength() != virtualLength) {
			this.virtualLength = virtualLength;
		}
	}

	public String getVirtualString() {
		StringBuilder sb = new StringBuilder(virtualLength);
		for (int i = 0; i < virtualLength; i++) {
			sb.append(' ');
		}
		return sb.toString();
	}

	// public void appendToDocumentContentBuilder() {
	// if (virtualLength >= 0) {
	// for (int i = 0; i < virtualLength; i++) {
	// documentContentBuilder.append(' ');
	// }
	// } else {
	// String s = documentContent.substring(position.getOffset(),
	// position.getOffset() + length());
	// documentContentBuilder.append(s);
	// }
	// }

	public int getVirtualLength() {
		return virtualLength;
	}
}
